let arr = [];
      if (window.localStorage.form === undefined) {
        window.localStorage.form = [];
      }

      $('.save').click(function () {
        let name = $('[name="name"]').val();
        let num = $('[name="num"]').val();
        let edu = $('[name="edu"]').val();
        let age = $('[name="age"]').val();
        let expect = $('[name="expect"]').val();

        // if (window.localStorage.form === undefined) {
        //   window.localStorage.form = [];
        //   console.log(window.localStorage.form);
        // }
        if (
          name.length === 0 ||
          num.length === 0 ||
          edu.length === 0 ||
          age.length === 0 ||
          expect.length === 0
        ) {
          window.alert('输入框不能为空');
          return;
        }

        //姓名;
        $('[name="name"]').change(function () {
          let reg1 = /^[a-zA-Z0-9]{8,16}$/;
          if (reg1.test(name)) {
            $('[name="name_span"]').html('');
          } else {
            $('[name="name_span"]').html('账号不符合格式，请重新输入').css('color', 'red');
            return;
          }
        });

        //电话
        $('[name="num"]').change(function () {
          let reg2 = /^1\d{10}$/;
          if (reg2.test(num)) {
            $('[name="num_span"]').html('');
          } else {
            $('[name="num_span"]').html('账号不符合格式，请重新输入').css('color', 'red');
            return;
          }
        });

        let arr1 = new setArr(name, num, edu, age, expect);
        arr.push(arr1);
        // console.log(arr);

        let arr_json = JSON.stringify(arr);
        // console.log(arr_json);
        window.localStorage.form = arr_json;

        name = $('[name="name"]').val('');
        num = $('[name="num"]').val('');
        edu = $('[name="edu"]').val('');
        age = $('[name="age"]').val('');
        expect = $('[name="expect"]').val('');
        setPage();
      });

      class setArr {
        constructor(name, num, edu, age, expect) {
          this.name = name;
          this.num = num;
          this.edu = edu;
          this.age = age;
          this.expect = expect;
        }
      }

      //修改按钮事件委托
      $('[name="tbody"]').click(function (e) {
        //修改按钮
        if (e.target.getAttribute('name') === 'fix') {
          $('.hidden-box').css('display', 'block');
          $('.cover').css('display', 'block');
          $('.save2').attr('index', Number(e.target.getAttribute('index')));
        } else if (e.target.getAttribute('name') === 'del') {
          //删除按钮

          let arr3 = JSON.parse(window.localStorage.form);

          arr3.splice(Number(e.target.getAttribute('index')), 1);
          //   console.log(arr3);
          let arr4 = JSON.stringify(arr3);
          window.localStorage.form = arr4;
          setPage();
        }
      });

      //修改页面事件委托
      $('.hidden-box').click(function (e) {
        // console.log(e.target.className);
        if (e.target.className === 'close') {
          $('.hidden-box').css('display', 'none');
          $('.cover').css('display', 'none');
        } else if (e.target.className === 'save2') {
          let name2 = $('[name="name2"]').val();
          let num2 = $('[name="num2"]').val();
          let edu2 = $('[name="edu2"]').val();
          let age2 = $('[name="age2"]').val();
          let expect2 = $('[name="expect2"]').val();

          //修改页面姓名;
          $('[name="name2"]').change(function () {
            let reg1 = /^[a-zA-Z0-9]{8,16}$/;
            if (reg1.test(name2)) {
              $('[name="name_span2"]').html('');
            } else {
              $('[name="name_span2"]').html('账号不符合格式，请重新输入').css('color', 'red');
              return;
            }
          });

          //修改页面电话
          $('[name="num2"]').change(function () {
            let reg2 = /^1\d{10}$/;
            if (reg2.test(num2)) {
              $('[name="num_span2"]').html('');
            } else {
              $('[name="num_span2"]').html('账号不符合格式，请重新输入').css('color', 'red');
              return;
            }
          });
          //   console.log(name.length);
          if (
            name2.length === 0 ||
            num2.length === 0 ||
            edu2.length === 0 ||
            age2.length === 0 ||
            expect2.length === 0
          ) {
            window.alert('输入框不能为空');
            return;
          }

          let arr2 = new setArr(name2, num2, edu2, age2, expect2);
          let formArr = JSON.parse(localStorage.form);

          formArr.splice(Number(e.target.getAttribute('index')), 1, arr2);
          //   console.log(Number(e.target.getAttribute('index')));
          //   console.log(arr);
          //   console.log(arr2);
          let arr_json = JSON.stringify(formArr);
          window.localStorage.form = arr_json;

          $('.hidden-box').css('display', 'none');
          $('.cover').css('display', 'none');
          setPage();
        }
      });

      function setPage() {
        let str = '';
        let formArr = JSON.parse(window.localStorage.form);
        // console.log(formArr);

        formArr.forEach((item, key) => {
          str += `
            <tr>
              <td>${item.name}</td>
              <td>${item.num}</td>
              <td>${item.edu}</td>
              <td>${item.age}</td>
              <td>${item.expect}</td>
              <td><button name="fix" index="${key}">修改</button><button name="del" index="${key}">删除</button></td>
            </tr>
            `;
        });
        $('[name="tbody"]').html(str);
      }